package com.gl.db.jdbc;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
import java.util.Properties;

import org.apache.commons.dbcp.BasicDataSource;

import com.gl.util.property.PropertyRead1;

public class JDBCTest {
	/**
	 * @param args
	 * @throws Exception 
	 */
	public static void main(String[] args) throws Exception {
		Connection conn = null;
		Statement stmt = null;
		ResultSet rs = null;
		try {
			//MySQL的JDBC加载
			Class.forName("com.mysql.jdbc.Driver");
		    conn = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/studb", "root", "root");
			stmt = conn.createStatement();
			 rs = stmt.executeQuery("select * from student");
			while(rs.next()){
				System.out.println("name:" + rs.getString("name") + ",年龄:" + rs.getString("age")
						+ ",部门:" + rs.getString("dept"));
			}
		} catch (Exception e) {
			// TODO: handle exception
		} finally{
			if(rs != null){
				rs.close();
			}
			if(stmt != null){
				rs.close();
			}
			if(conn != null){
				conn.close();
			}
		}

	}
}
